<template>
	<view>
		<view class="content">
      <view v-if="!detailedList.length" class="default-page">
        <image class="img" src="/static/image/none.png"></image>
        <view>暂无中奖记录</view>
      </view>
			<view v-else class="list" v-for="(item, index) in detailedList" :key="index">
				<view class="icon"></view>
				<view class="left">
					<view class="name">{{ getTitle(item.type, item.manor_title) }}</view>
					<view class="time">
            {{ item.time }}
					</view>
				</view>
				<view class="right" :class="item.flag === 'IN' ?'add':'sub'">
					<text>{{ getNum(item.flag,item.change) }}</text>Fdo
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	var than;
	export default {
		data() {
			return {
        detailedList: [],
        page: 1,
			}
		},
		onLoad(option) {
			than = this;
		},
    onShow() {
      than.page = 1
      than.getDobDetails()
    },
		methods: {
      /**
       * 获取明细内容
       */
      getDobDetails() {
        than.post("api/dob/dobDetailsList", {
          page: than.page
        }, function(data) {
          console.log(data)
          than.detailedList = data
        })
      },
      /**
       * 替换文字
       * @param type
       * @param title
       * @returns {string}
       */
      getTitle(type,title) {
        switch (type) {
          case 'GO_SHOPPING':
            return `购物消费`
          case 'WIN_PRICE':
            return  title?`中奖获得(${title})`:'中奖获得'
        }
      },
      /**
       * 替换数量
       * @param type
       * @param num
       * @returns {string}
       */
      getNum(type,num) {
        switch (type) {
          case 'IN':
            return `+${num}`
          case 'OUT':
            return  `-${num}`
        }
      }
		},
    onReachBottom() {
      than.page ++
      than.getDobDetails()
    },
	}
</script>

<style lang="less">
	page {
		background: #F4F4F7;
	}

  .default-page {
    margin-top: 80rpx;
    font-size: 26rpx;
    color: #BDC3D3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    .img {
      width: 226.4rpx;
      height: 213.7rpx;
    }
  }
	.content {
		padding: 24rpx 36rpx;

		.list {
			height: 130rpx;
			background: #FFFFFF;
			margin-bottom: 20rpx;
			border-radius: 20rpx;
			display: flex;
			align-items: center;
			padding: 0 24rpx;

			.icon {
				width: 24rpx;
				height: 24rpx;
				background: #004FFF;
				border-radius: 50%;
			}

			.left {
				margin-left: 24rpx;

				.name {
					font-size: 28rpx;
					font-family: PingFang SC;
					font-weight: bold;
				}

				.time {
					font-size: 24rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #666666;
				}
			}

			.right {
				margin-left: auto;
				font-size: 32rpx;
				font-family: DINCond-Black;
				font-weight: bold;
				display: flex;
				align-items: center;

				text {
					font-size: 36rpx;
				}
			}

			.add {
				color: #F66337;
			}

			.sub {
				color: #4A5062;
			}
		}
	}
</style>
